package com.dt76.smallloanbackendservice.controller.etao;

import com.dt76.smallloanbackendservice.pojo.etao.Meun;
import com.dt76.smallloanbackendservice.service.etao.MenuService;
import com.dt76.smallloanbackendservice.utils.MenuList;
import com.dt76.smallloanbackendservice.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class MenuController {

    @Autowired
    private MenuService menuService;


    @RequestMapping("/getAllMenu")
    @ResponseBody
    public List<Meun> getAllMenu() {
        return menuService.getMenuList();
    }

    @RequestMapping("/getMenuByRId")
    @ResponseBody
    public List<String> getMenuByRId(@RequestParam Integer rId) {
        return menuService.getMeunByRId(rId);
    }

    @RequestMapping("/editMenuByRId")
    @ResponseBody
    public Result editMenu(@RequestBody MenuList menuList) {
        Result result = new Result();
        result.setSuccess(menuService.editMenuRole(menuList));
        System.out.println(menuService.editMenuRole(menuList));
        return result;
    }
}
